package com.caseeye.repository

import org.springframework.stereotype.Component
import javax.annotation.Resource
import org.springframework.beans.factory.annotation.Required
import scala.reflect.BeanProperty
import com.caseeye.dao._
import com.caseeye.model._
import com.caseeye.base._

@Component
class CaseMasterRepository extends Repository {

    @Resource
    @Required
    @BeanProperty
    var caseMasterDAO : CaseMasterDAO = null

    def find(id : String) : CaseMaster = caseMasterDAO.findById(id, null)

    def findOrElse(id : String, orElse : CaseMaster) : CaseMaster = caseMasterDAO.findById(id, orElse)

    def findByTitle(title : String) = caseMasterDAO.findByTitle(title)

    def create() : CaseMaster = createRichDomainObject(classOf[CaseMaster])

    def remove(caseMaster : CaseMaster) : Boolean = caseMasterDAO.remove(caseMaster)

    def save(caseMaster : CaseMaster) : Boolean = caseMasterDAO.save(caseMaster)
    
    def findAll():List[CaseMaster] = caseMasterDAO.findAll
}